package parts4.lesson42;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        //创建具有3个大小的调度线程池
        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(3);
        for (int x = 0; x < 10; x++) {
            //Thread.sleep(100);
            int index = x;

            executorService.scheduleAtFixedRate(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + ",x=" + index);
                }
            }, 3, 10, TimeUnit.SECONDS);
        }
        //executorService.shutdown();
    }
}
